package com.xiaoxu.intranetweb.mybatisplusSzappdb.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.entity.CCompanyClass;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.entity.CCompanys;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 单位类型表 Mapper 接口
 * </p>
 *
 * @author xiaoxu
 * @since 2022-12-27
 */
@Component
@DS("szappdb")
public interface CCompanyClassMapper extends BaseMapper<CCompanyClass> {
//传入cpyClassId找到c_company_class的数据，然后根据c_company_class的cpyClassName再查出c_companys表CPY_CO_CLASS与cpyClassName相同的所有数据
@Select("SELECT * FROM c_companys WHERE CPY_CO_CLASS = (SELECT CPYCLASS_NAME FROM c_company_class WHERE CPYCLASS_ID = #{cpyClassId} and DATA_FROM = #{dataFrom} and CPYCLASS_DELETED = 0) and DATA_FROM = #{dataFrom} and CPY_DELETED = 0")
List<CCompanys> getCompanysByClassId(@Param("cpyClassId") Integer cpyClassId, @Param("dataFrom") String dataFrom);
}
